<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/5/4
 * Time: 15:31
 */

namespace Admin\Model;
use Think\Model;

class BannerModel extends Model
{
    protected $tableName = "banner";
    protected $tablePrefix = "dangjian_";

    public function queryAllBanner ()
    {
        $res = $this->select();
        return $res;
    }

    //保存banner图片到数据库
    public function saveBanner ($data)
    {
        $res = $this->data($data)->add();
        if($res > 0){
            return 1;
        }
        return 0;
    }

    public function updateShow($id,$is_show)
    {
        $this->where("id=$id")->save(array('is_show'=>$is_show));
    }

    public function queryBannerById ($id)
    {
        $res = $this->where("id=$id")->find();
        return $res;
    }

    public function saveEditBanner ($where,$data)
    {
//        echo '<pre>';
//        print_r($where);
//        print_r($data);die;
        $res = $this->where($where)->save($data);
//        echo $res;die;
        return $res;
    }
}